﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.IO;

namespace ClickNET.IO
{
    /// <summary>
    /// Object representing a single filesystem entity
    /// </summary>
    [XmlRoot]
    public abstract class FileEntity
    {
        public FileEntity() { }

        public FileEntity(string filePath)
        {
            this.Path = filePath;
        }

        /// <summary>
        /// Populate relevant file details
        /// </summary>
        protected internal virtual void Load()
        {
            if (File.Exists(this.Path))
            {
                System.IO.FileInfo fi = new System.IO.FileInfo(this.Path);
                this.Path = this.Path;
                this.FileName = fi.Name;
                this.FileSize = fi.Length;
            }
        }

        [XmlElement] public string FileName { get; set; }

        /// <summary>
        /// Absolute filesystem path
        /// </summary>
        [XmlElement] public string Path { get; set; }

        [XmlElement] public long FileSize { get; set; }
    }
}
